﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.kiosk {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class BuyKioskProductCommand extends Command {

        public var paymentModel:PaymentModel;
        public var worldModel:WorldModel;
        public var event:InfoEvent;

        override public function execute():void{
            var _local4:Object;
            var _local5:Object;
            var _local6:Object;
            var _local7:String;
            var _local8:Object;
            var _local9:InfoEvent;
            var _local1:Array = (this.paymentModel.getData("buy_craft_items") as Array);
            var _local2:Array = (this.paymentModel.getData("buy_coffee") as Array);
            var _local3:Array = _local1.concat(_local2);
            for each (_local5 in _local3) {
                if (_local5.product_id == this.event.id){
                    _local4 = _local5;
                    break;
                };
            };
            if (_local4){
                _local6 = this.event.info;
                _local7 = String(this.worldModel.getRoomIdsOfType(GameConstants.TYPE_KIOSK));
                _local8 = {product_id:_local4.product_id, product_type:ProtocolConstants.BUY_CRAFT_ITEMS, amount:_local4.amount, icon:_local4.icon, roomId:_local7, itemName:_local5.name, itemCode:_local6.code};
                _local9 = new InfoEvent(EventConstants.START_PAYMENT, null, _local8);
                dispatch(_local9);
            };
        }

    }
}//package net.wooga.pets.controllers.kiosk 
